package com.sxm.yiwei.adapters;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.sxm.yiwei.R;
import com.sxm.yiwei.activitis.NoticeMessageActivity;
import com.sxm.yiwei.beans.NoticeBeans;
import com.sxm.yiwei.tools.CastTime;

import java.util.List;

/**
 * Created by KuKa on 2017/9/20.
 */

public class NoticeListAdapter extends BaseAdapter{
    Context context;
    List<NoticeBeans.DataBean> data;
    public NoticeListAdapter(Context context, List<NoticeBeans.DataBean> data) {
        this.context=context;
        this.data=data;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        ViewHolder holder;
        if (convertView==null){
            view = View.inflate(context, R.layout.notice_item,null);
            holder = new ViewHolder();
            holder.typeImg = (ImageView) view.findViewById(R.id.noticeitem_typeimg);
            holder.typeTitle = (TextView) view.findViewById(R.id.noticeitem_title);
             holder.itemContent = (TextView) view.findViewById(R.id.noticeitem_content);
            holder.time = (TextView) view.findViewById(R.id.noticeitem_time);
            view.setTag(holder);
        }else {
            view=convertView;
            holder = (ViewHolder) view.getTag();
        }
       /* holder.typeTitle.setText("订单异常");
        holder.itemContent.setText("近日有消息称，广州富力地产股份有限公司拟寻求约119亿元人民币(约合18亿美元)境内担保贷款，用于对万达集团酒店资产的199亿元收购交易。");
        holder.time.setText("90 20 10:42");*/


        String code = data.get(position).getNotificationCode();
        Integer integer = Integer.valueOf(code);
        switch (integer){
            case 2000:// 订单申诉
                holder.typeImg.setImageResource(R.mipmap.ddss);
                break;
            case 2001:// 意见建议
                holder.typeImg.setImageResource(R.mipmap.yjjyj);
                break;
            case 2002:// 店铺举报
                holder.typeImg.setImageResource(R.mipmap.jb);
                break;
            case 2003:// 实名认证
                holder.typeImg.setImageResource(R.mipmap.smrz);
                break;
            case 2004:// 店铺审核
                holder.typeImg.setImageResource(R.mipmap.dpsh);
                break;
            case 2005:// 服务审核
                holder.typeImg.setImageResource(R.mipmap.fwsh);
                break;
            case 2006:// 充值
                holder.typeImg.setImageResource(R.mipmap.cz);
                break;
            case 2007:// 提现
                holder.typeImg.setImageResource(R.mipmap.tx);
                break;
            case 2008://一喂元等级
                holder.typeImg.setImageResource(R.mipmap.yyydj);
                break;
            case 2009:// 服务保障金
                holder.typeImg.setImageResource(R.mipmap.bzjjn);
                break;
        }
        holder.typeTitle.setText(data.get(position).getNotificationKind());
        holder.itemContent.setText(data.get(position).getNotificationMessage()+"     ");
        holder.time.setText(CastTime.streamTime(data.get(position).getNotificationCreateTime()));
        notifyDataSetChanged();
        return view;
    }

   class ViewHolder{
       private ImageView typeImg;
       private TextView typeTitle,itemContent,time;
   }
}
